//
//  XMGPictureViewController.m
//  BuDeJie
//
//  Created by xiaomage on 16/3/18.
//  Copyright © 2016年 小码哥. All rights reserved.
//

#import "XMGPictureViewController.h"

@interface XMGPictureViewController ()

@end

@implementation XMGPictureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor =RWRandomColor;
    
    self.tableView.contentInset = UIEdgeInsetsMake(RWNavMaxY + RWTitlesViewH, 0, RWTabBarH, 0);
    
    // 接受tabbar被重复点击的通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabBarButtonDidRepeatClick) name:RWTabBarButtonDidTepeatClickNotification object:nil];
    // 标题按钮被重复点击的通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabTitleButtonDidRepeatClick) name:RWTTitleButtonDidTepeatClickNotification object:nil];
}

- (void)dealloc {
    
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark - 监听
/**
 *  tabBarButton重复点击
 */
- (void)tabBarButtonDidRepeatClick {
    
    // 如果点击的不是精华按钮 && 显示在正中间的不在正中间
    if (self.view.window == nil)  return;
    if (self.tableView.scrollsToTop == NO) return;
    
    RWLog(@"%@--刷新数据", self.class);
}

/**
 *  标题按钮被重复点击
 */
- (void)tabTitleButtonDidRepeatClick {
    
    [self tabBarButtonDidRepeatClick];

}

#pragma mark - 数据源
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 30;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.backgroundColor = [UIColor clearColor];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%@-%zd", self.class, indexPath.row];
    return cell;
}

@end
